chore(solver): eliminate tuning magic-number drift hazards#163
Merged
Conversation
Numerical-hygiene pass on the solver crate for the pre-publication review. No behavior change: every default reproduces the previously hardcoded value. Biexp fast-grid dedup (biexp_fit.rs): - Hoist the fast-component grid bounds (0.25/2.0/0.5/8.0 x dt, 0.15 x tau_d) into shared named consts (TRF_*/TDF_*), used by both cold_grid_search and golden_section_refine so the two stages can no longer drift. - Fix a real drift: refinement floored tau_r_fast at 0.1 x dt while the grid floored at 0.25 x dt, letting refinement search a region the grid never saw. Refinement now clamps to the same shared bounds. - Resolve the two long-standing TODOs (sequential ceiling; dt-relative vs fixed-ms bounds) as documented design decisions with rationale. Seed/baseline/EMA config- ification: - Introduce SeedConfig (mad_multiplier, onset_fraction, max_walkback_s, min_peak_distance_s) with Default; find_seed_spikes reads from it instead of bare literals. FFI binding signatures (seed_trace, seed_kernel_estimate) unchanged. - Home the rolling-baseline percentile as baseline::DEFAULT_BASELINE_QUANTILE, used by both Solver::subtract_baseline and indeca::solve_trace (was the literal 0.2 duplicated across two modules). - Name the display-baseline EMA weight as BASELINE_EMA_WEIGHT. Tests: 131 Rust + 207 Python pass; clippy clean under jsbindings and pybindings. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Numerical-hygiene pass on the solver crate for the pre-publication review — closes the last correctness-adjacent items from the review checklist (fast-grid dedup + the two biexp TODOs) and removes remaining bare-literal / duplicated tuning constants per the no-magic-numbers rule. No behavior change: every default reproduces the previously hardcoded value.
Biexp fast-grid dedup (
biexp_fit.rs)0.25/2.0/0.5/8.0 × dt,0.15 × tau_d) into shared named consts (TRF_*/TDF_*), used by bothcold_grid_searchandgolden_section_refineso the two stages can no longer drift apart.tau_r_fastat0.1 × dtwhile the grid floored at0.25 × dt, letting refinement explore a region the grid never searched. Refinement now clamps to the same shared bounds (and thetau_d_fastrefine floor is clamped to the grid floor too).Seed / baseline / EMA config-ification
SeedConfig(mad_multiplier,onset_fraction,max_walkback_s,min_peak_distance_s) withDefault;find_seed_spikesreads from it instead of bare literals (4.0,0.10,1.0,5.0). FFI binding signatures (seed_trace,seed_kernel_estimate) are unchanged.baseline::DEFAULT_BASELINE_QUANTILE, used by bothSolver::subtract_baselineandindeca::solve_trace— previously the literal0.2was duplicated across two modules (a drift hazard like the fast-grid one).BASELINE_EMA_WEIGHT.Testing
clippyclean under both--features jsbindingsand--features pybindings.cargo fmt --all --checkclean.🤖 Generated with Claude Code